const path = require('path');
const fs = require('fs');

module.exports = app => {
  const config = exports = {};

  config.siteFile = {
    '/favicon.ico': fs.readFileSync(path.join(app.baseDir, 'app/web/asset/images/favicon.ico'))
  };

  config.view = {
    cache: false
  };

  config.vuessr = {
    layout: path.join(app.baseDir, 'app/web/view/layout.html'),
    renderOptions: {
      // 告诉 vue-server-renderer 去 app/view 查找异步 chunk 文件
      basedir: path.join(app.baseDir, 'app/view')
    }
  };

  config.logger = {
    consoleLevel: 'DEBUG',
    dir: path.join(app.baseDir, 'logs')
  };

  config.static = {
    prefix: '/',
    dir: path.join(app.baseDir, 'public')
  };

  config.keys = '123456';

  // 微信公众号配置 现在这个是随便写的！
  // config.weChatConfig = {
  //   token: '',
  //   appId: '',
  //   secret: '',
  //   encodingAESKey: ''
  // };


  config.session = {
    key: 'EGG_SESS',
    maxAge: 7 * 24 * 3600 * 1000, // 7 天
    httpOnly: true,
    encrypt: true,
  };

  config.middleware = [
    'access',
    'device'
  ];

  exports.security = {
    xframe: {
      enable: false,
    },
    domainWhiteList: ['res.wx.qq.com', 'api.map.baidu.com'], // 安全白名单，以 . 开头
  };

  return config;
};
